import trees
from math import log
import operator

# 构造数据集
myDat,labels = trees.createDataSet()

# 计算给定数据的香农熵
trees.calcShannonEnt(myDat)

# 按照给定特征划分数据集  
trees.splitDataSet(myDat,0,1)

# 选择最好的数据集划分方式 
trees.chooseBestFeatureToSplit(myDat)

# 创建树
myTree = trees.createTree(myDat,labels)

# 分类
trees.classify(myTree,labels,[1,0])
trees.classify(myTree,labels,[1,1])

# 使用pickle模块存储决策树
trees.storeTree(myTree,'classifierStorage.txt')
myTree = trees.storeTree('classifierStorage.txt')
